package com.helpers;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;

import com.model.Activity;
import com.model.Comment;
import com.model.Employee;
import com.model.Task;

public class TaskHelper {

	public static Task createTask()
	{
		Task task = new Task();
		task.setName("Task 1");
		task.setDescription("task Description");
		task.setProgress(87);
		task.setStartDate(new Date(0));
		task.setVisible(true);
		task.setComments(new ArrayList<Comment>());
		return task;
	}
	
	
	public static Task createTaskForEmployee(Employee employee)
	{
		Task task = new Task();
		task.setName("Task 1");
		task.setDescription("task Description");
		task.setProgress(87);
		task.setStartDate(new Date(0));
		task.setFinishDate(new Date(0));
		task.setVisible(true);
		task.setEmployee(employee);
		return task;
	}
	
	public static List<Task> createFiveTasksForActivity(Activity activity)
	{
		List <Task> tasks =  new ArrayList<Task>();
		Task task = new Task();
		task.setName("Task 0");
		task.setProgress(10);
		task.setVisible(true);
		task.setActivity(activity);
		task.setFinishDate(new Date(111, 5, 5));
		
		Task task1 = new Task();
		task1.setName("Task 1");
		task1.setProgress(10);
		task1.setVisible(true);
		task1.setActivity(activity);
		task1.setFinishDate(new Date(111, 7, 5));
		
		Task task2 = new Task();
		task2.setName("Task 2");
		task2.setProgress(10);
		task2.setVisible(true);
		task2.setActivity(activity);
		task2.setFinishDate(new Date(111, 7, 5));
		
		Task task3 = new Task();
		task3.setName("Task 3");
		task3.setProgress(10);
		task3.setVisible(true);
		task3.setActivity(activity);
		task3.setFinishDate(new Date(111, 5, 9));
		
		Task task4 = new Task();
		task4.setName("Task 4");
		task4.setProgress(10);
		task4.setVisible(true);
		task4.setActivity(activity);
		task4.setFinishDate(new Date(111, 2, 5));
		tasks.add(task);
		tasks.add(task1);
		tasks.add(task2);
		tasks.add(task3);
		tasks.add(task4);
		
		return tasks;
		
	}

	public static Activity createActivityWithTasksForEmployee(Employee employee) {
		Activity activity = ActivityHelper.createActivityForEmployee(employee);
		List<Task> temporaryTasks = createFiveTasksForActivity(activity);
		for (Task task : temporaryTasks) {
			task.setEmployee(employee);
		}
		HashSet<Task> tasks = new HashSet<Task>(temporaryTasks);
		activity.setTasks(tasks);
		return activity;
		
	}
}
